from django.db import models


# Create your models here.

class UserInfo(models.Model):
    StudentName = models.CharField(max_length=128, verbose_name='名称', help_text='学生的名字', null=False, blank=False,
                                   db_index=True)
    StudentID = models.CharField(max_length=12, verbose_name='学号', help_text='10位学号', unique=True, primary_key=True)
    StudentMajor = models.CharField(max_length=128, verbose_name='专业')
    StudentYear = models.CharField(max_length=4, verbose_name='年级')

    enable = models.BooleanField(verbose_name='状态', default=True)
    create_time = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
    update_time = models.DateTimeField(verbose_name='更新时间', auto_now=True)

    class Meta:
        verbose_name = "用户"
        verbose_name_plural = verbose_name+"管理"

    def __str__(self):
        return self.StudentName


class UserPW(models.Model):
    StudentID = models.OneToOneField(UserInfo, on_delete=models.CASCADE)
    Password = models.CharField(max_length=128, verbose_name='密码')

    class Meta:
        verbose_name = "用户密码"
        verbose_name_plural = verbose_name+"管理"

    def __str__(self):
        return self.StudentName
